package com.jiaai.cloud.user.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jiaai.cloud.active.entity.TActivity;
import com.jiaai.cloud.base.exception.ServiceException;
import com.jiaai.cloud.base.page.CustomPage;
import com.jiaai.cloud.base.page.FrontPage;
import com.jiaai.cloud.base.util.RestResultGenerator;
import com.jiaai.cloud.user.entity.TUserPayRecord;
import com.jiaai.cloud.user.entity.TUserPayRecordSeach;
import com.jiaai.cloud.user.service.ITUserPayRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户交易信息表 前端控制器
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-08-29
 */
@RestController
@RequestMapping("/api/manage/tUserPayRecord")
public class TUserPayRecordController {
    @Autowired
    private ITUserPayRecordService itUserPayRecordService;

    @RequestMapping(value = "/findByAll", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Object findByAll(TUserPayRecordSeach search) throws ServiceException {
        try {
            EntityWrapper wrapper=new EntityWrapper();
            if(search.getType()!=null){
                wrapper.eq("type",search.getType());
            }
            if(search.getSysType()!=null){
                wrapper.eq("sysType",search.getSysType());
            }
            Page page=search.getPagePlus();
            itUserPayRecordService.findFully(page,wrapper);
            return RestResultGenerator.genSuccessResult(new CustomPage(page));
        } catch (Exception e) {
            throw new ServiceException("查询失敗", e.getMessage());
        }
    }

    //删
    @RequestMapping(value ="/deleteId/{recordId}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public Object deleteId(@PathVariable("recordId") Integer recordId) throws ServiceException {
        try {
            itUserPayRecordService.deleteById(recordId);
            return RestResultGenerator.genSuccessResult();
        } catch (Exception e) {
            throw new ServiceException("删除失敗", e.getMessage());
        }
    }
}
